import axios from 'axios';

// Create axios instance with base URL and default headers
const api = axios.create({
  baseURL: 'http://localhost:3000', // Change this to your backend URL
  headers: {
    'Content-Type': 'application/json',
  },
});

// API endpoints for different resources
export const categoryAPI = {
  getAll: () => api.get('/categories'),
  getById: (id: string) => api.get(`/categories/${id}`),
};

export const productAPI = {
  getAll: () => api.get('/products'),
  getById: (id: string) => api.get(`/products/${id}`),
  getByCategory: (categoryId: string) => api.get(`/products/category/${categoryId}`),
};

export const shopAPI = {
  getAll: () => api.get('/shops'),
  getById: (id: string) => api.get(`/shops/${id}`),
};

export const orderAPI = {
  getAll: () => api.get('/orders'),
  getById: (id: string) => api.get(`/orders/${id}`),
};

export const afterSalesAPI = {
  getAll: () => api.get('/aftersales'),
};

export default api; 